Update the 'run_with_library_paths' test to reflect the new filtering.
authorPeter Williams <peter@newton.cx>
Tue, 7 Feb 2017 05:13:37 +0000 (00:13 -0500)
committerPeter Williams <peter@newton.cx>
Tue, 7 Feb 2017 05:15:30 +0000 (00:15 -0500)
For the library paths to be passed through, they must reside within the build
output directory.

tests/run.rs

index bca7680cf1f305ffeb2829e8846828052967e6d6..8caa3c7e7e0581a11fc02e24fcf764a87562a86b 100644 (file)
@@ -597,30 +597,37 @@ hello
 
 #[test]
 fn run_with_library_paths() {
-    let p = project("foo")
-        .file("Cargo.toml", r#"
+    let mut p = project("foo");
+
+    // Only link search directories within the target output directory are
+    // propagated through to dylib_path_envvar() (see #3366).
+    let mut dir1 = p.target_debug_dir();
+    dir1.push("foo");
+
+    let mut dir2 = p.target_debug_dir();
+    dir2.push("dir=containing=equal=signs");
+
+    p = p.file("Cargo.toml", r#"
             [project]
             name = "foo"
             version = "0.0.1"
             authors = []
             build = "build.rs"
         "#)
-        .file("build.rs", r#"
-            fn main() {
-                println!("cargo:rustc-link-search=native=foo");
-                println!("cargo:rustc-link-search=bar");
-                println!("cargo:rustc-link-search=/path=containing=equal=signs");
-            }
-        "#)
+        .file("build.rs", &format!(r#"
+            fn main() {{
+                println!("cargo:rustc-link-search=native={}");
+                println!("cargo:rustc-link-search={}");
+            }}
+        "#, dir1.display(), dir2.display()))
         .file("src/main.rs", &format!(r#"
             fn main() {{
                 let search_path = std::env::var_os("{}").unwrap();
                 let paths = std::env::split_paths(&search_path).collect::<Vec<_>>();
-                assert!(paths.contains(&"foo".into()));
-                assert!(paths.contains(&"bar".into()));
-                assert!(paths.contains(&"/path=containing=equal=signs".into()));
+                assert!(paths.contains(&"{}".into()));
+                assert!(paths.contains(&"{}".into()));
             }}
-        "#, dylib_path_envvar()));
+        "#, dylib_path_envvar(), dir1.display(), dir2.display()));
 
     assert_that(p.cargo_process("run"), execs().with_status(0));
 }